#include<bits/stdc++.h>
#define eb emplace_back
#define ep emplace

using namespace std;
using ll = long long;

void solve() {
    int n, m, L, V;
    cin >> n >> m >> L >> V;

    vector<int> d(n), v(n), a(n), p(m);
    for(int i = 0; i < n; ++ i) {
        cin >> d[i] >> v[i] >> a[i];
    }
    for(int i = 0; i < m; ++ i) cin >> p[i];
    int tot = 0;
    vector<pair<int, int>> seq;

    auto check = [&](int i, int j) {
        if(j >= m || d[i] > p[j]) return false;
        return v[i] * v[i] + 2 * a[i] * ll(p[j] - d[i]) > V * V;
    };
    for(int i = 0; i < n; ++ i) {
        int nxt = lower_bound(p.begin(), p.end(), d[i]) - p.begin();
        if(!check(i, a[i] > 0 ? m - 1 : nxt)) continue;
        ++ tot;
        int l = nxt, r = m - 1;
        if(a[i] < 0) {
            while(l < r) {
                int mid = l + r + 1 >> 1;
                check(i, mid) ? l = mid : r = mid - 1;
            }
            seq.eb(nxt, l);
        }
        else {
            while(l < r) {
                int mid = l + r >> 1;
                check(i, mid) ? r = mid : l = mid + 1;
            }
            seq.eb(l, m - 1);
        }
    }
    if(seq.empty()) {
        cout << 0 << ' ' << m << '\n';
        return;
    }
    sort(seq.begin(), seq.end(), [&](auto A, auto B) {
        if(A.second != B.second) return A.second < B.second;
        return A.first < B.first;
    });
    int f = 1, g = seq[0].second;
    for(int i = 1; i < seq.size(); ++ i) {
        if(g >= seq[i].first) continue;
        ++ f;
        g = max(g, seq[i].second);
    }
    cout << tot << ' ' << m - f << '\n';
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin.tie(0)->sync_with_stdio(0);
    
    int T;
    cin >> T;

    while(T --) {
        solve();
    }
    return 0;
}